<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
defined('_JEXEC') or die;

$data = array();
foreach ($this->items as $item) {
    $data[$item->section_id][] = $item;
}
?>
<?php if ($this->params->def('show_page_heading', 1)) : ?>
    <h1 class="campus-title">
        <?php echo $this->escape($this->params->get('page_heading')); ?>
    </h1>
<?php endif; ?>

<div class="cproject-sections">
    <?php
    foreach ($data as $section) {
        $secLink = JRoute::_('index.php?option=com_cproject&view=section&id='.$section[0]->slug);
        $i = 1;
        ?>
        <h4><a href="<?php echo $secLink; ?>"><?php echo $section[0]->secname; ?></a></h4>
        <?php
        foreach ($section as $cproject) {
           $cproLink = JRoute::_('index.php?option=com_cproject&view=cproject&cid='.$cproject->slug . '&id='. $cproject->gslug);
            ?>
            <h5><small><?php echo $i; ?>.</small> <a href="<?php echo $cproLink; ?>"><?php echo $cproject->name; ?></a></h5>
            <?php
            $i++;
        }
    }
    ?>

</div>
